package com.gyg.controller;


import com.gyg.client.CloudRecordClient;
import com.gyg.domain.CloudUser;
import com.gyg.enums.SessionEnum;
import com.gyg.returns.RespEntity;
import com.gyg.returns.RespTable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * <p>
 * 文件上传下载记录表 前端控制器
 * </p>
 *
 * @author gyg
 * @since 2021-04-14
 */
@RestController
@RequestMapping("/cloud-record")
@Api(value = "记录模块", tags = "记录模块")
@Slf4j
public class CloudRecordController {

    @Resource
    private CloudRecordClient cloudRecordClient;

    @ApiOperation(value = "操作记录列表")
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "optionType", value = "操作类型，1=上传，2=下载", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "username", value = "用户账号", required = false)
    })
    public RespTable cloudRecordList(@RequestParam(value = "optionType", required = true) Integer optionType,
                                     @RequestParam(value = "page", required = true) Integer page,
                                     @RequestParam(value = "limit", required = true) Integer limit,
                                     @RequestParam(value = "username", required = false) String username) {
        RespTable respTable = cloudRecordClient.cloudRecordList(optionType, page, limit, username);
        return respTable;
    }

    @GetMapping("/uploadCount")
    @ApiOperation(value = "文件上传统计")
    public RespEntity uploadCount() {
        RespEntity respEntity = cloudRecordClient.uploadCount();
        return respEntity;
    }

    @GetMapping("/downloadCount")
    @ApiOperation(value = "文件下载统计")
    public RespEntity downloadCount() {
        RespEntity respEntity = cloudRecordClient.downloadCount();
        return respEntity;
    }

}
